{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import backtrader as bt\n",
    "from qmtbt import QMTStore\n",
    "from datetime import datetime\n",
    "from xtquant import xtdata\n",
    "\n",
    "\n",
    "class DemoStrategy(bt.Strategy):\n",
    "\n",
    "\tdef __init__(self):\n",
    "\t\tpass\n",
    "\tdef next(self):\n",
    "\t\tpass\n",
    "\tdef notify_data(self, data, status, *args, **kwargs):\n",
    "\t\tprint(data.close[0])\n",
    "\n",
    "cerebro = bt.Cerebro()\n",
    "\n",
    "store = QMTStore()\n",
    "\n",
    "code_list = xtdata.get_stock_list_in_sector('沪深300')\n",
    "\n",
    "print(code_list)\n",
    "\n",
    "datas = store.getdatas(code_list=code_list, timeframe=bt.TimeFrame.Days, fromdate=datetime(2022, 7, 1), live=True)\n",
    "\n",
    "store.setdatas(cerebro, datas)\n",
    "\n",
    "# data = store.getdata(dataname='600519.SH', timeframe=bt.TimeFrame.Days, fromdate=datetime(2022, 1, 1), dividend_type='front', live=True)\n",
    "# cerebro.adddata(data)\n",
    "cerebro.addstrategy(DemoStrategy)\n",
    "\n",
    "cerebro.run()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "qmtbt-W-3m0aVF-py3.10",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
